package com.seelyn.dowork.repositories;

import com.seelyn.dowork.entities.Comment;
import com.seelyn.dowork.entities.CommentExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface CommentMapper {
    @SelectProvider(type=CommentSqlProvider.class, method="countByExample")
    long countByExample(CommentExample example);

    @DeleteProvider(type=CommentSqlProvider.class, method="deleteByExample")
    int deleteByExample(CommentExample example);

    @Delete({
        "delete from st_comment",
        "where comment_id = #{commentId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long commentId);

    @Insert({
        "insert into st_comment (comment_id, created_on, ",
        "del_flag, updated_on, ",
        "audit_flag, email, ",
        "star, title, course_id, ",
        "content)",
        "values (#{commentId,jdbcType=BIGINT}, #{createdOn,jdbcType=TIMESTAMP}, ",
        "#{delFlag,jdbcType=VARCHAR}, #{updatedOn,jdbcType=TIMESTAMP}, ",
        "#{auditFlag,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, ",
        "#{star,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{courseId,jdbcType=BIGINT}, ",
        "#{content,jdbcType=LONGVARCHAR})"
    })
    int insert(Comment record);

    @InsertProvider(type=CommentSqlProvider.class, method="insertSelective")
    int insertSelective(Comment record);

    @SelectProvider(type=CommentSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="comment_id", property="commentId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="star", property="star", jdbcType=JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Comment> selectByExampleWithBLOBsWithRowbounds(CommentExample example, RowBounds rowBounds);

    @SelectProvider(type=CommentSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="comment_id", property="commentId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="star", property="star", jdbcType=JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Comment> selectByExampleWithBLOBs(CommentExample example);

    @SelectProvider(type=CommentSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="comment_id", property="commentId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="star", property="star", jdbcType=JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT)
    })
    List<Comment> selectByExampleWithRowbounds(CommentExample example, RowBounds rowBounds);

    @SelectProvider(type=CommentSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="comment_id", property="commentId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="star", property="star", jdbcType=JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT)
    })
    List<Comment> selectByExample(CommentExample example);

    @Select({
        "select",
        "comment_id, created_on, del_flag, updated_on, audit_flag, email, star, title, ",
        "course_id, content",
        "from st_comment",
        "where comment_id = #{commentId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="comment_id", property="commentId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="created_on", property="createdOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_flag", property="delFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="updated_on", property="updatedOn", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="audit_flag", property="auditFlag", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="star", property="star", jdbcType=JdbcType.INTEGER),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="course_id", property="courseId", jdbcType=JdbcType.BIGINT),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    Comment selectByPrimaryKey(Long commentId);

    @UpdateProvider(type=CommentSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Comment record, @Param("example") CommentExample example);

    @UpdateProvider(type=CommentSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Comment record, @Param("example") CommentExample example);

    @UpdateProvider(type=CommentSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Comment record, @Param("example") CommentExample example);

    @UpdateProvider(type=CommentSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Comment record);

    @Update({
        "update st_comment",
        "set created_on = #{createdOn,jdbcType=TIMESTAMP},",
          "del_flag = #{delFlag,jdbcType=VARCHAR},",
          "updated_on = #{updatedOn,jdbcType=TIMESTAMP},",
          "audit_flag = #{auditFlag,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "star = #{star,jdbcType=INTEGER},",
          "title = #{title,jdbcType=VARCHAR},",
          "course_id = #{courseId,jdbcType=BIGINT},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where comment_id = #{commentId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKeyWithBLOBs(Comment record);

    @Update({
        "update st_comment",
        "set created_on = #{createdOn,jdbcType=TIMESTAMP},",
          "del_flag = #{delFlag,jdbcType=VARCHAR},",
          "updated_on = #{updatedOn,jdbcType=TIMESTAMP},",
          "audit_flag = #{auditFlag,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "star = #{star,jdbcType=INTEGER},",
          "title = #{title,jdbcType=VARCHAR},",
          "course_id = #{courseId,jdbcType=BIGINT}",
        "where comment_id = #{commentId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Comment record);
}